{extend name="ashippingguide/Public/base" /}
{block name="container"}
<div class="page-heade">
    <h2 class="title_color text-center">导购岗位管理</h2>
</div>
<form action="" class="form-inline" id="form1" method="post">
    <table class="table table-bordered bud_hei" style="margin-bottom: 0">
        <tr>
            <td colspan="9"><a href="javascript:;" class="btn btn-sm btn-primary" id="addguidegw">添加导购岗位</a><span class="lr_5"></span><a href="{:url('ashippingguide/import')}" class="btn btn-sm btn-info">导入导购岗位</a><span class="lr_5"></span><a onclick='window.open("/index/ashippingguide/export","_self")' class="btn btn-sm btn-info">导出Excel</a><span class="lr_5 colorRed">注：本功能用于导购员选择岗位之用。</span></td>
        </tr>
    </table>
<table class="table table-striped table-bordered table-hover bud_hei text-center">
    <tr class="info">
        <th class="text-center">No.</th>
        <th class="text-center">导购岗位名称</th>
        <th class="text-center">创建人</th>
        <th class="text-center">创建时间</th>
        <th class="text-center">修改人</th>
        <th class="text-center">修改时间</th>
        <th class="text-center">维护</th>
    </tr>
    <tbody style="border: 0">
    {volist name="data" id="list"}
    <tr>
        <td>{$i}</td>
        <td>{$list.guideName}</td>
        <td>{$list.createUser}</td>
        <td>{$list.createDate}</td>
        <td>{$list.modifyUser}</td>
        <td>{$list.modifyDate}</td>
        <td><a href="javascript:;" onclick="edit({$list.id})" class="modify">修改</a>&nbsp;<a href="javascript:;" onclick="del({$list.id})" class="delthis">删除</a></td>
    </tr>
    {/volist}
    </tbody>
</table>
    <h5 class="text-center" style="font-size: 13px;font-weight: 500">
        总共有{$count}条记录，第{$page}/{$maxpage}页,当前页<input id="page" name="pages" type="text" style="width: 40px" value="1"/>
        <button id="gopage">Go</button>&nbsp;&nbsp;<button
            id="fistpage" onclick="$('#form1').find('input').val('');">首页
    </button>&nbsp;&nbsp;
        每页显示
        <select id="pagesize" name="limts">
            <option value='10' selected>10条</option>
            <option value='15'>15条</option>
            <option value='20'>20条</option>
        </select>
        <script>
            $('#pagesize').val("{$limit}");
        </script>
    </h5>
</form>

<div id="addlaborcontractDiv" class="ibox-content" style="display: none;">
    <form action="{:url('Ashippingguide/postAdd')}" class="form-inline" method="post" id="form2">
        <input type="hidden" name="id" value="" id="id">
        <table class="table table-bordered">
            <tr>
                <td style="width: 140px" class="text-center">导购岗位名称<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control validate[required,ajax[guideName]]" id="guideName" name="guideName" value="">(导购岗位名称不能重复)</td>
            </tr>
            <tr>
                <td class="text-center">显示次序<span class="colorRed">*</span></td>
                <td><input type="text" class="form-control validate[required]" name="sort" id="sort" value="{$sort}"></td>
            </tr>
        </table>
    </form>
</div>
<script>
    $('#form2').validationEngine('attach', {
        promptPosition: 'bottomRight'
    });

    $("#addguidegw").click(function(){
        layer.open({
            type: 1,
            title: '导购岗位管理',
            area: ['900px', '400px'],
            fixed: false, //不固定
            maxmin: true,
            btn:["提交","返回"],
            content: $('#addlaborcontractDiv'),
            yes: function (i, o) {
                    $('#form2').submit();

               //     var param = $('#form1').serialize()
               // $.post('/index/workflowdb/ysfy_cg.html', param, function (data) {
               //     if (data.success) {
               //         swal({title: data.msg}, function () {
               //             layer.close(i)
               //             location.reload()
               //         })
               //     } else {
               //         swal(data.msg)
               //     }
               // }, 'json')
           }
        });


    })
    // $(document).ready(function () {
    //     $('#reset').on('click',function () {
    //         $("#form1 input").each(function(){
    //             $(this).val('');
    //         });
    //         $("#form1 select").each(function(){
    //             $(this).val('');
    //         });
    //         $('#form1').submit()
    //         return false
    //     })
    //
    //
    // })

    /*返回*/
    // $('#fanhui').on('click',function () {
    //     // parent.layer.close(parent.layer.getFrameIndex(window.name))
    //     location.reload();
    //     return false
    // })
    /*修改*/
    function edit(id){
        $.get("{:url('Ashippingguide/postEditP')}", {id:id}, function (e) {
            if(e.success){
                $('#id').val(e.data.id);
                $('#guideName').val(e.data.guideName);
                $('#sort').val(e.data.sort);
                layer.open({
                    type: 1,
                    title: '修改导购岗位',
                    area: ['900px', '600px'],
                    fixed: false, //不固定
                    maxmin: true,
                    btn:["确认修改","返回"],
                    content: $('#addlaborcontractDiv'),
                    yes: function (i, o) {
                        $('#form2').submit();
                    }
                });
            }else{
                swal('主键错误！')
            }
        }, 'json');

    }
//     $(document).on("click",".modify",function(){
//         layer.open({
//             type: 1,
//             title: '修改导购岗位',
//             area: ['900px', '600px'],
//             fixed: false, //不固定
//             maxmin: true,
//             btn:["确认修改","返回"],
//             content: $('#addlaborcontractDiv')
//             /*   yes: function (i, o) {
//                    var param = $('#form1').serialize()
//                $.post('/index/workflowdb/ysfy_cg.html', param, function (data) {
//                    if (data.success) {
//                        swal({title: data.msg}, function () {
//                            layer.close(i)
//                            location.reload()
//                        })
//                    } else {
//                        swal(data.msg)
//                    }
//                }, 'json')
//            }
// */
//         });
//
//     })
    /*删除*/

    // $(document).on("click",".delthis",function(){
    //     swal({
    //             title: "确定此操作吗？",
    //             text: "",
    //             type: "warning",
    //             showCancelButton: true,
    //             confirmButtonColor: "#DD6B55",
    //             confirmButtonText: "确定！",
    //             closeOnConfirm: false
    //         },
    //         function(){
    //             swal("", "", "success");
    //         });
    // })

    function del(id){
        swal({
                title: "确定此操作吗？",
                text: "",
                type: "warning",
                showCancelButton: true,
                confirmButtonColor: "#DD6B55",
                confirmButtonText: "确定！",
                closeOnConfirm: false
            },
            function(){
                $.get("{:url('Ashippingguide/postDel')}", {id:id}, function (e) {
                    if(e.success){
                        location.reload();
                    }else{
                        swal('主键错误！');
                    }
                }, 'json');
            });
    }

</script>
{/block}